package com.gitee.fanx.retty.web;

/**
 * @author fanhang
 */
public abstract class Base64Utils {

	private static final java.util.Base64.Encoder ENCODER = java.util.Base64.getUrlEncoder();

	private static final java.util.Base64.Decoder DECODER = java.util.Base64.getDecoder();

	public static String encode(String toEncodeContent) {
		if (toEncodeContent == null) {
			return null;
		}
		return ENCODER.encodeToString(toEncodeContent.getBytes());
	}

	public static String decode(String toDecodeContent) {
		if (toDecodeContent == null) {
			return null;
		}
		try {
			byte[] buf = DECODER.decode(toDecodeContent);
			return new String(buf);
		} catch (Exception e) {
			throw e;
		}
	}

}
